package www.ld.com.domain.department.vo;

import cn.hutool.core.bean.BeanUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import www.ld.com.dictionary.UseStatusEnum;
import www.ld.com.domain.department.pojo.DepartmentPO;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

@Data
@Accessors(chain = true)
@ToString
@EqualsAndHashCode
@ApiModel(value = "DepartmentVO",description =  "部门列表")
public class DepartmentVO  {
   @ApiModelProperty(value  = "部门Id")
   private String id;
   @ApiModelProperty(value = "部门名称")
   private String name;
   @ApiModelProperty(value = "部门状态")
   private UseStatusEnum status;
   @ApiModelProperty(value = "创建时间")
   @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
   private LocalDateTime createDate;
    @ApiModelProperty(value = "排序")
   private int sort;

   @ApiModelProperty(value = "上级部门ID")
   private String parentId;

   public static List<DepartmentVO> departmentPOToDepartmentVO(List<DepartmentPO> departmentPOS){
     return  departmentPOS.stream().map(v -> {
         return BeanUtil.toBean(v, DepartmentVO.class);
      }).collect(Collectors.toList());
   }


}
